﻿<Fluent:RibbonWindow xmlns:my="clr-namespace:iConverter" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Fluent="clr-namespace:Fluent;assembly=Fluent"
    xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:my1="clr-namespace:System;assembly=mscorlib"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" 
    xmlns:Commands="clr-namespace:iConverter.Commands" 
    xmlns:iConverter="clr-namespace:iConverter"           
    x:Name="MainWindow"    
    x:Class="MainWindow"
    AllowDrop="True" 
    Title="iConverter" Height="600" Width="800" Icon="/iConverter;component/Logo/iConverter.ico" >
    <Fluent:RibbonWindow.Resources>

        <Fluent:ObjectToImageConverter x:Key="StringToImageConvert"/>

        <ControlTemplate x:Key="BackstageLabelTemplate" TargetType="{x:Type Label}">
            <Grid Margin="0,0,10,0">
                <TextBlock FontSize="{TemplateBinding FontSize}" FontWeight="Bold" Foreground="#FF5E5E5E" Margin="0,5" Text="{TemplateBinding Content}" TextWrapping="Wrap" VerticalAlignment="Center" />
                <Path Data="M0,0L1,0" Fill="{x:Null}" Height="1" Margin="0" Stretch="Fill" Stroke="{DynamicResource RibbonTopBorderBrush}" StrokeDashArray="2 2" StrokeEndLineCap="Flat" StrokeLineJoin="Miter" StrokeMiterLimit="10" StrokeStartLineCap="Flat" StrokeThickness="1" VerticalAlignment="Bottom" />
            </Grid>
        </ControlTemplate>
        <Style x:Key="BackstageLabelStyle" TargetType="{x:Type Label}">
            <Setter Property="Template" Value="{StaticResource BackstageLabelTemplate}" />
            <Setter Property="FontSize" Value="14" />
        </Style>
        <Style x:Key="RibbonButtonBackStageStyle" TargetType="{x:Type Fluent:Button}">
            <Setter Property="Template" Value="{DynamicResource BackStageRibbonButtonControlTemplate}"/>
            <Setter Property="OverridesDefaultStyle" Value="True"/>
            <Setter Property="Height" Value="91"/>
            <Setter Property="Width" Value="Auto"/>
            <Setter Property="FontSize" Value="{DynamicResource DefaultFontSize}"/>
            <Setter Property="FontFamily" Value="{DynamicResource DefaultFontFamily}"/>
            <Setter Property="Foreground" Value="{DynamicResource DefaultFontBrush}"/>
            <Setter Property="FocusVisualStyle" Value="{DynamicResource ControlStyleEmptyFocus}"/>
            <Setter Property="SnapsToDevicePixels" Value="False"/>
            <Setter Property="HorizontalAlignment" Value="Stretch" />
            <Style.Triggers>
                <Trigger Property="Fluent:RibbonControl.Size" Value="Large">
                    <Setter Property="Height" Value="91"/>
                    <Setter Property="Width" Value="Auto"/>
                </Trigger>
                <Trigger Property="Fluent:RibbonControl.Size" Value="Middle">
                    <Setter Property="Height" Value="91"/>
                    <Setter Property="Width" Value="Auto"/>
                    <!--<Setter Property="HorizontalAlignment" Value="Left"/>-->
                </Trigger>
                <Trigger Property="Fluent:RibbonControl.Size" Value="Small">
                    <Setter Property="Height" Value="53"/>
                    <Setter Property="Width" Value="Auto"/>
                    <!--<Setter Property="HorizontalAlignment" Value="Left"/>-->
                </Trigger>
            </Style.Triggers>
        </Style>
        <ControlTemplate x:Key="BackStageRibbonButtonControlTemplate" TargetType="{x:Type Fluent:Button}">
            <Border x:Name="border" BorderThickness="1" CornerRadius="2" Background="{DynamicResource TransparentBrush}" BorderBrush="{DynamicResource TransparentBrush}" Height="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                <Border x:Name="border1" Height="Auto" BorderBrush="{DynamicResource TransparentBrush}" BorderThickness="1" CornerRadius="2" Background="{DynamicResource TransparentBrush}">
                    <Grid >
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Rectangle x:Name="rectangle" StrokeThickness="0" Visibility="Collapsed" Grid.ColumnSpan="2">
                            <Rectangle.Fill>
                                <RadialGradientBrush Center="0.503,1" GradientOrigin="0.503,1" RadiusY="0.202">
                                    <GradientStop Color="#7FFFFFFF" Offset="0"/>
                                    <GradientStop Offset="1"/>
                                </RadialGradientBrush>
                            </Rectangle.Fill>
                        </Rectangle>

                        <ContentPresenter Grid.Column="0" x:Name="iconImage" HorizontalAlignment="Center" Height="64" Width="64" VerticalAlignment="Center" Content="{Binding LargeIcon, Converter={StaticResource StringToImageConvert}, RelativeSource={RelativeSource TemplatedParent}}"  Margin="4,12,0,12" SnapsToDevicePixels="True" />
                        <Fluent:TwoLineLabel Grid.Column="1" x:Name="controlLabel" Text="{TemplateBinding Header}" Style="{DynamicResource TwoLineLabelBackStageStyle}" HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="18,10,5,10" FontSize="{TemplateBinding FontSize}" />

                     
                    </Grid>
                </Border>
            </Border>
            <ControlTemplate.Triggers>
                <Trigger Property="Size" Value="Small">
                    <Setter Property="FontSize" TargetName="controlLabel" Value="14"/>
                    <Setter Property="HasTwoLines" TargetName="controlLabel" Value="False"/>
                    <Setter Property="Width" TargetName="iconImage" Value="32"/>
                    <Setter Property="Height" TargetName="iconImage" Value="32"/>
                    <Setter Property="Margin" TargetName="iconImage" Value="5,9,0,9"/>
                    <Setter Property="Content" TargetName="iconImage" Value="{Binding Icon, Converter={StaticResource StringToImageConvert}, RelativeSource={RelativeSource TemplatedParent}}"/>
                    <Setter Property="Margin" TargetName="controlLabel" Value="18,0,2,2"/>
                </Trigger>
                <Trigger Property="Size" Value="Middle">
                    <Setter Property="HasTwoLines" TargetName="controlLabel" Value="False"/>
                    <Setter Property="FontSize" TargetName="controlLabel" Value="14"/>
                </Trigger>
                <Trigger Property="Size" Value="Large">
                    <Setter Property="HasTwoLines" TargetName="controlLabel" Value="True"/>
                    <Setter Property="FontSize" TargetName="controlLabel" Value="14"/>
                </Trigger>
                <Trigger Property="IsPressed" Value="True">
                    <Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource ButtonPressedOuterBorderBrush}"/>
                    <Setter Property="Background" TargetName="border" Value="{DynamicResource ButtonPressedOuterBackgroundBrush}"/>
                    <Setter Property="Background" TargetName="border1" Value="{DynamicResource ButtonPressedInnerBackgroundBrush}"/>
                    <Setter Property="BorderBrush" TargetName="border1" Value="{DynamicResource ButtonPressedInnerBorderBrush}"/>
                </Trigger>
                <Trigger Property="IsEnabled" Value="False">
                    <Setter Property="Opacity" TargetName="iconImage" Value="0.5"/>
                    <Setter Property="Opacity" TargetName="controlLabel" Value="0.5"/>
                    <Setter Property="Effect" TargetName="iconImage">
                        <Setter.Value>
                            <Fluent:GrayscaleEffect/>
                        </Setter.Value>
                    </Setter>
                </Trigger>
                <MultiTrigger>
                    <MultiTrigger.Conditions>
                        <Condition Property="IsMouseOver" Value="True"/>
                        <Condition Property="IsPressed" Value="False"/>
                        <Condition Property="IsEnabled" Value="True"/>
                    </MultiTrigger.Conditions>
                    <Setter Property="BorderBrush" TargetName="border1" Value="{DynamicResource ButtonHoverInnerBorderBrush}"/>
                    <Setter Property="Background" TargetName="border1" Value="{DynamicResource ButtonHoverInnerBackgroundBrush}"/>
                    <Setter Property="Background" TargetName="border" Value="{DynamicResource ButtonHoverOuterBackgroundBrush}"/>
                    <Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource ButtonHoverOuterBorderBrush}"/>
                    <Setter Property="Visibility" TargetName="rectangle" Value="Visible"/>
                </MultiTrigger>
                <MultiTrigger>
                    <MultiTrigger.Conditions>
                        <Condition Property="IsKeyboardFocusWithin" Value="True"/>
                        <Condition Property="IsPressed" Value="False"/>
                    </MultiTrigger.Conditions>
                    <Setter Property="BorderBrush" TargetName="border1" Value="{DynamicResource ButtonHoverInnerBorderBrush}"/>
                    <Setter Property="Background" TargetName="border1" Value="{DynamicResource ButtonHoverInnerBackgroundBrush}"/>
                    <Setter Property="Background" TargetName="border" Value="{DynamicResource ButtonHoverOuterBackgroundBrush}"/>
                    <Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource ButtonHoverOuterBorderBrush}"/>
                </MultiTrigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>

        <Style x:Key="TwoLineLabelBackStageStyle" TargetType="{x:Type Fluent:TwoLineLabel}" >
            <Setter Property="Template" Value="{DynamicResource BackStageTwoLineLabelControlTemplate}"/>
          
        </Style>
        <ControlTemplate x:Key="BackStageTwoLineLabelControlTemplate" TargetType="{x:Type Fluent:TwoLineLabel}">
            <StackPanel x:Name="stackPanel" Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="0">
                <AccessText TextWrapping="Wrap" TextAlignment="Left" HorizontalAlignment="Left" VerticalAlignment="Center" x:Name="PART_TextRun" />
                <AccessText TextWrapping="Wrap" TextAlignment="Left" HorizontalAlignment="Left" VerticalAlignment="Center" x:Name="PART_TextRun2" />
                <StackPanel x:Name="stackPanel1" Margin="0" Orientation="Vertical" HorizontalAlignment="Left" VerticalAlignment="Center" Visibility="Collapsed">
                    <Border x:Name="border" Height="Auto" Width="5" HorizontalAlignment="Center" Margin="0">
                        <Path x:Name="path" Width="5" Height="3" StrokeThickness="0" Data="M0,0L5,0 2.5,3z" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,2,0,0"  RenderOptions.BitmapScalingMode="NearestNeighbor" SnapsToDevicePixels="True" Fill="{TemplateBinding Foreground}" Visibility="Collapsed" />
                    </Border>
                </StackPanel>
            </StackPanel>


            <ControlTemplate.Triggers>
                <Trigger Property="HasTwoLines" Value="False">
                    <Setter  TargetName="PART_TextRun2" Property="Visibility" Value="Collapsed"/>
                
                </Trigger>
                <Trigger Property="HasGlyph" Value="False">
               
                </Trigger>
            </ControlTemplate.Triggers>


        </ControlTemplate>
        <Style x:Key="TabItemFocusVisual">
            <Setter Property="Control.Template">
                <Setter.Value>
                    <ControlTemplate>
                        <Rectangle Margin="3,3,3,1" SnapsToDevicePixels="true" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" StrokeThickness="1" StrokeDashArray="1 2"/>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <SolidColorBrush x:Key="TabControlNormalBorderBrush" Color="#8C8E94"/>
        <LinearGradientBrush x:Key="ButtonNormalBackground" EndPoint="0,1" StartPoint="0,0">
            <GradientStop Color="#F3F3F3" Offset="0"/>
            <GradientStop Color="#EBEBEB" Offset="0.5"/>
            <GradientStop Color="#DDDDDD" Offset="0.5"/>
            <GradientStop Color="#CDCDCD" Offset="1"/>
        </LinearGradientBrush>
        <LinearGradientBrush x:Key="TabItemHotBackground" EndPoint="0,1" StartPoint="0,0">
            <GradientStop Color="#EAF6FD" Offset="0.15"/>
            <GradientStop Color="#D9F0FC" Offset=".5"/>
            <GradientStop Color="#BEE6FD" Offset=".5"/>
            <GradientStop Color="#A7D9F5" Offset="1"/>
        </LinearGradientBrush>
        <SolidColorBrush x:Key="TabItemSelectedBackground" Color="#F9F9F9"/>
        <SolidColorBrush x:Key="TabItemHotBorderBrush" Color="#3C7FB1"/>
        <SolidColorBrush x:Key="TabItemDisabledBackground" Color="#F4F4F4"/>
        <SolidColorBrush x:Key="TabItemDisabledBorderBrush" Color="#FFC9C7BA"/>



        <ControlTemplate x:Key="CloseButtonTemplate" TargetType="{x:Type ButtonBase}">
            <Border x:Name="border" 
                    BorderBrush="Transparent"   BorderThickness="2" Background="Transparent" 
                    HorizontalAlignment="Center" VerticalAlignment="Center" 
                    Width="13" Height="13"
                    >
                <Path x:Name="pathx" Data="F1M0,0L2,0 5,3 8,0 10,0 6,4 10,8 8,8 5,5 2,8 0,8 4,4 0,0z" Fill="Silver"  
                      HorizontalAlignment="Center" VerticalAlignment="Center"/>
            </Border>
            <ControlTemplate.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="BorderBrush" TargetName="border" Value="Gold"/>
                    <Setter Property="Fill" TargetName="pathx" Value="Black"/>
                    <Setter Property="Background" TargetName="border" Value="DarkOrange"/>
                </Trigger>
                <Trigger Property="IsEnabled" Value="False">
                    <Setter Property="Fill" TargetName="pathx" Value="LightGray"/>
                </Trigger>
                <Trigger Property="IsPressed" Value="True">
                    <Setter Property="Background" TargetName="border" Value="Goldenrod"/>
                    <Setter Property="Fill" TargetName="pathx" Value="White"/>
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>



        <Style x:Key="DocumentTabItemStyle" TargetType="{x:Type TabItem}">
            <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
            <Setter Property="VerticalContentAlignment" Value="Stretch"/>
            <Setter Property="HeaderTemplate">
                <Setter.Value>
                    <DataTemplate>
                        <TextBlock Text="{Binding Name}"   />
                    </DataTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="ContentTemplate">
                <Setter.Value>
                    <DataTemplate>
                        <Grid>
                            <TextBox HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Visible" AcceptsReturn="True" AcceptsTab="True" Background="White" Text="{Binding Mode=TwoWay, Path=Content, UpdateSourceTrigger=PropertyChanged}" />
                        </Grid>
                    </DataTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type TabItem}">
                        <Grid SnapsToDevicePixels="true">
                            <Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1,1,1,0"  Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" CornerRadius="3" Margin="0,0,0,-2">
                                <StackPanel Orientation="Horizontal" >
                                    <ContentPresenter x:Name="Content" ContentSource="Header" 
                                                      HorizontalAlignment="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"
                                                      RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
                                                      VerticalAlignment="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
                                    <Button x:Name="btnclose" Visibility="Collapsed" VerticalAlignment="Center" 
                                            HorizontalAlignment="Center" Template="{DynamicResource CloseButtonTemplate}" 
                                            Margin="3,0,0,0" Command="ApplicationCommands.Close" CommandParameter="{Binding }"  />
                                </StackPanel>
                            </Border>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="true">
                                <Setter Property="Background" TargetName="Bd" Value="{StaticResource TabItemHotBackground}"/>
                            </Trigger>
                            <Trigger Property="IsSelected" Value="true">
                                <Setter Property="Panel.ZIndex" Value="1"/>
                                <Setter Property="Background" TargetName="Bd" Value="{StaticResource TabItemSelectedBackground}"/>
                                <Setter Property="Visibility" TargetName="btnclose" Value="Visible" />
                            </Trigger>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="IsSelected" Value="false"/>
                                    <Condition Property="IsMouseOver" Value="true"/>
                                </MultiTrigger.Conditions>
                                <Setter Property="BorderBrush" TargetName="Bd" Value="{StaticResource TabItemHotBorderBrush}"/>
                            </MultiTrigger>
                            <Trigger Property="TabStripPlacement" Value="Bottom">
                                <Setter Property="BorderThickness" TargetName="Bd" Value="1,0,1,1"/>
                            </Trigger>
                            <Trigger Property="TabStripPlacement" Value="Left">
                                <Setter Property="BorderThickness" TargetName="Bd" Value="1,1,0,1"/>
                            </Trigger>
                            <Trigger Property="TabStripPlacement" Value="Right">
                                <Setter Property="BorderThickness" TargetName="Bd" Value="0,1,1,1"/>
                            </Trigger>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="IsSelected" Value="true"/>
                                    <Condition Property="TabStripPlacement" Value="Top"/>
                                </MultiTrigger.Conditions>
                                <Setter Property="Margin" Value="-2,-2,-2,-1"/>
                                <Setter Property="Margin" TargetName="Content" Value="0,0,0,1"/>
                            </MultiTrigger>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="IsSelected" Value="true"/>
                                    <Condition Property="TabStripPlacement" Value="Bottom"/>
                                </MultiTrigger.Conditions>
                                <Setter Property="Margin" Value="-2,-1,-2,-2"/>
                                <Setter Property="Margin" TargetName="Content" Value="0,1,0,0"/>
                            </MultiTrigger>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="IsSelected" Value="true"/>
                                    <Condition Property="TabStripPlacement" Value="Left"/>
                                </MultiTrigger.Conditions>
                                <Setter Property="Margin" Value="-2,-2,-1,-2"/>
                                <Setter Property="Margin" TargetName="Content" Value="0,0,1,0"/>
                            </MultiTrigger>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="IsSelected" Value="true"/>
                                    <Condition Property="TabStripPlacement" Value="Right"/>
                                </MultiTrigger.Conditions>
                                <Setter Property="Margin" Value="-1,-2,-2,-2"/>
                                <Setter Property="Margin" TargetName="Content" Value="1,0,0,0"/>
                            </MultiTrigger>
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter Property="Background" TargetName="Bd" Value="{StaticResource TabItemDisabledBackground}"/>
                                <Setter Property="BorderBrush" TargetName="Bd" Value="{StaticResource TabItemDisabledBorderBrush}"/>
                                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>


        <Style x:Key="DocumentTabControlStyle" TargetType="{x:Type TabControl}">
            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
            <Setter Property="Padding" Value="4,4,4,4"/>
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="BorderBrush" Value="{StaticResource TabControlNormalBorderBrush}"/>
            <Setter Property="Background" Value="#F9F9F9"/>
            <Setter Property="HorizontalContentAlignment" Value="Center"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="ItemContainerStyle" Value="{DynamicResource DocumentTabItemStyle}" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type TabControl}">
                        <Grid ClipToBounds="true" SnapsToDevicePixels="true" KeyboardNavigation.TabNavigation="Local">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition x:Name="ColumnDefinition0"/>
                                <ColumnDefinition x:Name="ColumnDefinition1" Width="0"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition x:Name="RowDefinition0" Height="Auto"/>
                                <RowDefinition x:Name="RowDefinition1" Height="*"/>
                            </Grid.RowDefinitions>
                            <TabPanel x:Name="HeaderPanel" Grid.Column="0" IsItemsHost="true" Margin="2,2,2,0" Grid.Row="0" KeyboardNavigation.TabIndex="1" Panel.ZIndex="1"/>
                            <Border x:Name="ContentPanel" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Grid.Column="0" KeyboardNavigation.DirectionalNavigation="Contained" Grid.Row="1" KeyboardNavigation.TabIndex="2" KeyboardNavigation.TabNavigation="Local">
                                <Grid>
                                    <Image Source="Images\iConverterShow1.png" Stretch="Uniform" StretchDirection="DownOnly" HorizontalAlignment="Center" VerticalAlignment="Center"  >
        
                                    </Image>
                                    <ContentPresenter x:Name="PART_SelectedContentHost" ContentSource="SelectedContent" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                                </Grid>
                            </Border>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="TabStripPlacement" Value="Bottom">
                                <Setter Property="Grid.Row" TargetName="HeaderPanel" Value="1"/>
                                <Setter Property="Grid.Row" TargetName="ContentPanel" Value="0"/>
                                <Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
                                <Setter Property="Height" TargetName="RowDefinition1" Value="Auto"/>
                                <Setter Property="Margin" TargetName="HeaderPanel" Value="2,0,2,2"/>
                            </Trigger>
                            <Trigger Property="TabStripPlacement" Value="Left">
                                <Setter Property="Grid.Row" TargetName="HeaderPanel" Value="0"/>
                                <Setter Property="Grid.Row" TargetName="ContentPanel" Value="0"/>
                                <Setter Property="Grid.Column" TargetName="HeaderPanel" Value="0"/>
                                <Setter Property="Grid.Column" TargetName="ContentPanel" Value="1"/>
                                <Setter Property="Width" TargetName="ColumnDefinition0" Value="Auto"/>
                                <Setter Property="Width" TargetName="ColumnDefinition1" Value="*"/>
                                <Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
                                <Setter Property="Height" TargetName="RowDefinition1" Value="0"/>
                                <Setter Property="Margin" TargetName="HeaderPanel" Value="2,2,0,2"/>
                            </Trigger>
                            <Trigger Property="TabStripPlacement" Value="Right">
                                <Setter Property="Grid.Row" TargetName="HeaderPanel" Value="0"/>
                                <Setter Property="Grid.Row" TargetName="ContentPanel" Value="0"/>
                                <Setter Property="Grid.Column" TargetName="HeaderPanel" Value="1"/>
                                <Setter Property="Grid.Column" TargetName="ContentPanel" Value="0"/>
                                <Setter Property="Width" TargetName="ColumnDefinition0" Value="*"/>
                                <Setter Property="Width" TargetName="ColumnDefinition1" Value="Auto"/>
                                <Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
                                <Setter Property="Height" TargetName="RowDefinition1" Value="0"/>
                                <Setter Property="Margin" TargetName="HeaderPanel" Value="0,2,2,2"/>
                            </Trigger>
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <my1:Double x:Key="BackStageGridColumnMaxWidth">400</my1:Double>
        <DataTemplate x:Key="EncodingItemTemplate">
            <TextBlock Text="{Binding EncodingName}" />
        </DataTemplate>
     


    </Fluent:RibbonWindow.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <Fluent:Ribbon x:Name="ribMain" Title="iConverter" IsQuickAccessToolBarVisible="False">

          
            <!--Contextual Tab Groups-->
            <Fluent:Ribbon.ContextualGroups>
                <Fluent:RibbonContextualTabGroup x:Name="BatchTabGroup" Header="批处理" Visibility="Visible" Background="Green" BorderBrush="Green" />
            </Fluent:Ribbon.ContextualGroups>

            <!--Backstage-->
            <Fluent:Ribbon.Menu  >
                <Fluent:Backstage Background="Green" >
                    <Fluent:BackstageTabControl>

                       

                        <Fluent:Button x:Name="btnNew"  Header="新建" Icon="Images\NewDocument_32x32.png" Command="ApplicationCommands.New" CommandTarget="{Binding ElementName=MainWindow}" />


                        <Fluent:Button x:Name="btnSave" Header="保存" Icon="Images\Save_16x16.png" LargeIcon="Images\Save_32x32.png" Command="ApplicationCommands.Save" CommandTarget="{Binding ElementName=MainWindow}"  />

                    

                        <Fluent:Button x:Name="btnClose" Header="关闭"  Icon="Images\Close_16x16.png" LargeIcon="Images\Close_32x32.png"  Command="ApplicationCommands.Close" CommandTarget="{Binding ElementName=MainWindow}"  />


                        <Fluent:BackstageTabItem x:Name="OpenBackstageTabItem" Header="打开" >
                            <ScrollViewer     VerticalAlignment="Stretch" VerticalContentAlignment="Stretch"  VerticalScrollBarVisibility="Auto"  HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch"  HorizontalScrollBarVisibility="Auto" >
                                <Grid   Margin="20,5,20,5" >
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="4*" MaxWidth="{StaticResource BackStageGridColumnMaxWidth}" />
                                        <ColumnDefinition Width="6*" MaxWidth="{StaticResource BackStageGridColumnMaxWidth}"/>
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="*" />
                                    </Grid.RowDefinitions>
                                    <Label Style="{StaticResource BackstageLabelStyle}" Grid.Row="0" Grid.Column="0" Content="打开文件"/>

                                    <Fluent:Button x:Name="btnOpen"
                                                   Grid.Row="1" Grid.Column="0"
                                                   Margin="3"
                                                   IsDefinitive="True"
                                                   HorizontalAlignment="Left"
                                                   Style="{DynamicResource ButtonBackstageStyle}"
                                                   Icon="Images\Open_32x32.png" 
                                                   LargeIcon="Images\Open_32x32.png" 
                                                   Command="ApplicationCommands.Open"
                                                   CommandTarget="{Binding ElementName=MainWindow}" 
                                                   Header="打开文件"/>

                                    <!--<Label Style="{StaticResource BackstageLabelStyle}" Grid.Row="2" Grid.Column="0" Content="最近打开的文件"/>


                                    <ListBox Grid.Row="3" Grid.Column="0" BorderThickness="0" Background="{x:Null}"  >
                                        <ListBoxItem Content="123"/>
                                        <ListBoxItem Content="123"/>
                                        <ListBoxItem Content="123"/>
                                        <ListBoxItem Content="123"/>
                                        <ListBoxItem Content="123"/>
                                    </ListBox>-->
                                </Grid>
                            </ScrollViewer>
                        </Fluent:BackstageTabItem>

                        <!--高级保存-->
                        <Fluent:BackstageTabItem x:Name="SaveBackstageTabItem" Header="另存为"  >
                            <ScrollViewer    VerticalAlignment="Stretch" VerticalContentAlignment="Stretch"  VerticalScrollBarVisibility="Auto"  HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch"  HorizontalScrollBarVisibility="Auto" >
                                <TabControl  Margin="20,5,20,5"  Style="{DynamicResource InnerBackstageTabControlStyle}" SelectedIndex="1" >
                                    <Fluent:SeparatorTabItem Header="保存方式"/>
                                    <TabItem Header="另存为" >
                                        <StackPanel Margin="10">
                                            <Fluent:Button x:Name="btnSaveAs"
                                                           Margin="3"
                                                           IsDefinitive="True"
                                                           HorizontalAlignment="Left"
                                                           Style="{DynamicResource ButtonBackstageStyle}"
                                                           Icon="Images\SaveAs_32x32.png" 
                                                           LargeIcon="Images\SaveAs_32x32.png" 
                                                           Command="ApplicationCommands.SaveAs"
                                                           CommandTarget="{Binding ElementName=MainWindow}" 
                                                           Header="另存为"/>
                                        </StackPanel>

                                    </TabItem>
                                    <TabItem Header="高级保存">
                                        <StackPanel   Margin="10">
                                            <Label Style="{StaticResource BackstageLabelStyle}"  Content="请选择保存文件的字符编码"  />

                                            <ListBox x:Name="lstSaveEncodings" 
                                                     IsEnabled="{Binding IsSelectDocument}"
                                                     ItemTemplate="{StaticResource EncodingItemTemplate}" 
                                                     ItemsSource="{Binding DestinationEncodingList}"
                                                     SelectedIndex="0"
                                                     >
                                                <!--SelectedValue="{Binding Path=SelectDocumentDestinationEncoding,Mode=OneTime}"-->

                                            </ListBox>

                                            <Fluent:Button  x:Name="btnSaveAdv" 
                                                            Margin="3"
                                                            IsDefinitive="True"
                                                            HorizontalAlignment="Left"
                                                            Style="{DynamicResource ButtonBackstageStyle}"
                                                            Icon="Images\SaveAdv_16x16.png" 
                                                            LargeIcon="Images\SaveAdv_32x32.png" 
                                                            Command="Commands:iConverterCommands.SaveADVCommand"
                                                            CommandParameter="{Binding Path=SelectedValue, ElementName=lstSaveEncodings, Mode=TwoWay}"
                                                            CommandTarget="{Binding ElementName=MainWindow}" 
                                                            Header="高级保存"/>

                                        </StackPanel>
                                    </TabItem>


                                </TabControl>
                            </ScrollViewer>
                        </Fluent:BackstageTabItem>

                        <Fluent:BackstageTabItem x:Name="SendToBackstageTabItem" Header="发送" >
                            <ScrollViewer      VerticalAlignment="Stretch" VerticalContentAlignment="Stretch"  VerticalScrollBarVisibility="Auto"  HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch"  HorizontalScrollBarVisibility="Auto" >
                                <Grid  Margin="20,5,20,5" >
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="4*" MaxWidth="{StaticResource BackStageGridColumnMaxWidth}" />
                                        <ColumnDefinition Width="6*" MaxWidth="{StaticResource BackStageGridColumnMaxWidth}" />
                                    </Grid.ColumnDefinitions>

                                    <StackPanel Grid.Column="0">
                                        <Label Style="{StaticResource BackstageLabelStyle}" Content="发送"/>
                                               
                                        <ListBox x:Name="lstPluginSends" Margin="3" 
                                                 HorizontalContentAlignment="Stretch" ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                                                 ScrollViewer.VerticalScrollBarVisibility="Auto" 
                                                 ItemsSource="{Binding PluginSends}" BorderThickness="0">
                                            
                                            <ListBox.ItemTemplate>
                                                <DataTemplate>
                                                    <Fluent:Button 
                                                        IsDefinitive="True" 
                                                        Style="{DynamicResource RibbonButtonBackStageStyle}"
                                                        Icon="{Binding SmallIcon }" 
                                                        LargeIcon="{Binding Icon }" Size="Small"  
                                                        Header="{Binding Name}" 
                                                        Command="Commands:iConverterCommands.SendCommand"
                                                        CommandParameter="{Binding }"
                                                        CommandTarget="{Binding ElementName=MainWindow}" 
                                                        Margin="3"
                                                            />
                                                </DataTemplate>
                                            </ListBox.ItemTemplate>
                                           
                                        </ListBox>
                                        

                                    </StackPanel>
                                </Grid>
                            </ScrollViewer>
                        </Fluent:BackstageTabItem>

                        <Fluent:BackstageTabItem x:Name="HelpBackstageTabItem" Header="帮助">
                            <ScrollViewer    VerticalAlignment="Stretch" VerticalContentAlignment="Stretch"  VerticalScrollBarVisibility="Auto"  HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch"  HorizontalScrollBarVisibility="Auto" >
                                <Grid Margin="20,5,20,5"   Grid.IsSharedSizeScope="False" >
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition SharedSizeGroup="SharedHelpColumnWidth" MaxWidth="{StaticResource BackStageGridColumnMaxWidth}" />
                                        <ColumnDefinition Width="3" />
                                        <ColumnDefinition SharedSizeGroup="SharedHelpColumnWidth" MaxWidth="{StaticResource BackStageGridColumnMaxWidth}" />
                                    </Grid.ColumnDefinitions>

                                    <StackPanel Grid.Column="0">
                                        <Label Style="{StaticResource BackstageLabelStyle}" Content="帮助"/>

                                        <Fluent:Button  x:Name="btnHelp"
                                                        IsDefinitive="True" 
                                                        Style="{DynamicResource RibbonButtonBackStageStyle}"
                                                        Icon="Images\Help_48x48.png" 
                                                        LargeIcon="Images\Help_64x64.png" Size="Middle" 
                                                        Command="ApplicationCommands.Help"
                                                        CommandTarget="{Binding ElementName=MainWindow}" 
                                                        CommandParameter="{Binding LinkHelp}"
                                                        Header="iConverter 帮助" 
                                                        />

                                        <Fluent:Button x:Name="btnStartUse"
                                                       IsDefinitive="True" 
                                                       Style="{DynamicResource RibbonButtonBackStageStyle}"
                                                       Icon="Images\StartUse_64x64.png" 
                                                       LargeIcon="Images\StartUse_64x64.png" Size="Middle" 
                                                       Command="Commands:iConverterCommands.StartUseCommand"
                                                       CommandTarget="{Binding ElementName=MainWindow}" 
                                                       CommandParameter="{Binding LinkStartUse}"
                                                       Header="开始使用"     />



                                        <Label Style="{StaticResource BackstageLabelStyle}" Content="设置工具"/>

                                        <Fluent:Button x:Name="btnSettings"
                                                       IsDefinitive="True" 
                                                       Style="{DynamicResource RibbonButtonBackStageStyle}"
                                                       Icon="Images\Settings_32x32.png" 
                                                       LargeIcon="Images\Settings_64x64.png" Size="Middle" 
                                                       Command="Commands:iConverterCommands.SettingsCommand"
                                                       CommandTarget="{Binding ElementName=MainWindow}" 
                                                       CommandParameter="{x:Static iConverter:OptionTabs.General}"
                                                       Header="选项" 
                                                       />

                                        <Fluent:Button x:Name="btnCheckUpdate"
                                                       IsDefinitive="True" 
                                                       Style="{DynamicResource RibbonButtonBackStageStyle}"
                                                       Icon="Images\CheckUpdate_64x64.png" 
                                                       LargeIcon="Images\CheckUpdate_64x64.png" Size="Middle" 
                                                       Command="Commands:iConverterCommands.CheckUpdateCommand"
                                                       CommandTarget="{Binding ElementName=MainWindow}" 
                                                       CommandParameter="{Binding LinkCheckUpdate}"
                                                       Header="检查更新" 
                                                       />

                                        <Fluent:Button x:Name="btnVisitWebSite"
                                                       IsDefinitive="True" 
                                                       Style="{DynamicResource RibbonButtonBackStageStyle}"
                                                       Icon="Images\WebPage_64x64.png" 
                                                       LargeIcon="Images\WebPage_64x64.png" Size="Middle" 
                                                       Command="Commands:iConverterCommands.WebSiteCommand"
                                                       CommandTarget="{Binding ElementName=MainWindow}" 
                                                       CommandParameter="{Binding LinkWebSite}"
                                                       Header="访问iConverter项目网站" 
                                                       />

                                    </StackPanel>

                                    <Rectangle Grid.Column="1" Width="1" HorizontalAlignment="Center" >
                                        <Rectangle.Fill>
                                            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                                <GradientStop Offset="1" Color="#00D2D3D4"/>
                                                <GradientStop Color="#7FD2D3D4"/>
                                                <GradientStop Color="#FFD2D3D4" Offset="0.246"/>
                                                <GradientStop Color="#FFD2D3D4" Offset="0.797"/>
                                            </LinearGradientBrush>
                                        </Rectangle.Fill>
                                    </Rectangle>

                                    <StackPanel Grid.Column="2" TextBlock.FontSize="12">
                                        <Image Source="Images\iConverterShow3.png" Stretch="UniformToFill" Width="315" />

                                        <Label Style="{StaticResource BackstageLabelStyle}" Content="支持"/>

                                        <Fluent:Button x:Name="btnPendingRequest"
                                                       IsDefinitive="True" 
                                                       Style="{DynamicResource RibbonButtonBackStageStyle}"
                                                       Icon="Images\PendingRequest_64x64.png" 
                                                       LargeIcon="Images\PendingRequest_64x64.png" Size="Middle" 
                                                       Command="Commands:iConverterCommands.PendingRequestCommand"
                                                       CommandTarget="{Binding ElementName=MainWindow}" 
                                                       CommandParameter="{Binding LinkPendingRequest}"
                                                       Header="寻求帮助" 
                                                       />

                                        <Fluent:Button x:Name="btnFeedback"
                                                       IsDefinitive="True" 
                                                       Style="{DynamicResource RibbonButtonBackStageStyle}"
                                                       Icon="Images\FeedBack_64x64.png" 
                                                       LargeIcon="Images\FeedBack_64x64.png" Size="Middle" 
                                                       Command="Commands:iConverterCommands.FeedbackCommand"
                                                       CommandTarget="{Binding ElementName=MainWindow}" 
                                                       CommandParameter="{Binding LinkFeedback}"
                                                       Header="问题反馈" 
                                                       />

                                        <Fluent:Button x:Name="btnContactus"
                                                       IsDefinitive="True" 
                                                       Style="{DynamicResource RibbonButtonBackStageStyle}"
                                                       Icon="Images\contactus_64x64.png" 
                                                       LargeIcon="Images\contactus_64x64.png" Size="Middle" 
                                                       Command="Commands:iConverterCommands.ContactusCommand"
                                                       CommandTarget="{Binding ElementName=MainWindow}" 
                                                       CommandParameter="{Binding LinkContactus}"
                                                       Header="与我联系" 
                                                       />

                                        <Label Style="{StaticResource BackstageLabelStyle}" Content="关于 iConveter"/>


                                        <my:AboutControl FontSize="12" />

                                    </StackPanel>
                                </Grid>
                            </ScrollViewer>
                        </Fluent:BackstageTabItem>


                        <Fluent:Button Header="选项" Icon="Images\Settings_32x32.png" LargeIcon="Images\Settings_64x64.png" 
                                       Command="{x:Static Commands:iConverterCommands.SettingsCommand }" 
                                       CommandParameter="{x:Static iConverter:OptionTabs.General}" 
                                       CommandTarget="{Binding ElementName=MainWindow}" />
                        <Fluent:Button Header="退出" Icon="Images\Exit.png" Command="Commands:iConverterCommands.ExitCommand" CommandTarget="{Binding ElementName=MainWindow}" />



                    </Fluent:BackstageTabControl>
                </Fluent:Backstage>
            </Fluent:Ribbon.Menu>

            <!--Tabs-->

            <Fluent:RibbonTabItem x:Name="rtiStart">
               
                <Fluent:RibbonTabItem.Header>
                    <TextBlock><Run Text="开始"/></TextBlock>
                </Fluent:RibbonTabItem.Header>

                <Fluent:RibbonGroupBox       Header="剪切板">

                    <Fluent:Button   Icon="Images\Copy_16x16.png"         LargeIcon="Images\Copy_48x48.png"  Header="复制" Command="ApplicationCommands.Copy" >
                    
                    </Fluent:Button>
                    <Fluent:Button  Icon="Images\Paste_16x16.png" LargeIcon="Images\Paste_32x32.png"   Header="粘贴" Command="ApplicationCommands.Paste" />
                </Fluent:RibbonGroupBox>

                <Fluent:RibbonGroupBox x:Name="rgbEncodings"      Header="字符编码">
                    <Fluent:ComboBox x:Name="cmbSourceEncodings"  Header="来源编码：" 
                                     IsEnabled="{Binding IsSelectDocument}"
                                     IsEditable="False" SelectedIndex="0" Width="250"
                                     ItemTemplate="{StaticResource EncodingItemTemplate}" 
                                     ItemsSource="{Binding SourceEncodingList}"
                                     SelectedValue="{Binding Path=SelectDocumentSourceEncoding, Mode=TwoWay }">
                       
                    </Fluent:ComboBox>
                    <Fluent:ComboBox x:Name="cmbDestinationEncoding"  Header="目标编码："  IsEditable="False" SelectedIndex="0"
                                     IsEnabled="{Binding IsSelectDocument}"
                                     Width="250" IsReadOnly="True"
                                     ItemTemplate="{StaticResource EncodingItemTemplate}" 
                                     ItemsSource="{Binding DestinationEncodingList}" 
                                     SelectedValue="{Binding Path=SelectDocumentDestinationEncoding, Mode=TwoWay }">
                       
                    </Fluent:ComboBox>
                </Fluent:RibbonGroupBox>

                <Fluent:RibbonGroupBox Header="插件">



                    <Fluent:SplitButton x:Name="sltbtnAutoUsePostProcessings" Icon="Images\Convert_32x32.png"  LargeIcon="Images\Convert_64x64.png" 
                                        Header="插件"  SizeDefinition="Large" IsCheckable="True"
                                        IsChecked="{Binding IsAutoUsePostProcessings,Mode=TwoWay}"
                                        ItemsSource="{Binding PostProcessingMenuItems }" >
        

                    </Fluent:SplitButton>


                    <Fluent:SplitButton Icon="Images\Send_32x32.png"  LargeIcon="Images\Send_48x48.png"  
                                        Header="自动发送"  SizeDefinition="Large" IsCheckable="True" 
                                        IsChecked="{Binding IsAutoUseSend,Mode=TwoWay}"
                                        ItemsSource="{Binding PluginSendMenuItems }">





                    </Fluent:SplitButton>

                    <Fluent:Button Size="Middle"    Icon="Images\Settings_32x32.png"    Header="插件设置"   Command="Commands:iConverterCommands.SettingsCommand"  CommandParameter="{x:Static iConverter:OptionTabs.Plugins}"  />
                    <Fluent:Button Size="Middle"   Icon="Images\Settings_32x32.png"    Header="转换设置"   Command="Commands:iConverterCommands.SettingsCommand"  CommandParameter="{x:Static iConverter:OptionTabs.Conversion}"  />

                </Fluent:RibbonGroupBox>

                <Fluent:RibbonGroupBox       Header="转换">
                    <Fluent:Button x:Name="btnConvert"  Icon="Images\Convert_32x32.png"  LargeIcon="Images\Convert_64x64.png"  Header="转换"
                                   Command="{x:Static Commands:iConverterCommands.ConvertCommand }" />

                </Fluent:RibbonGroupBox>



            </Fluent:RibbonTabItem>





            <Fluent:RibbonTabItem x:Name="rtiPlugins" >
                <Fluent:RibbonTabItem.Header>
                    <TextBlock><Run Text="插件"/></TextBlock>
                </Fluent:RibbonTabItem.Header>


                <Fluent:RibbonGroupBox Header="插件">


                    <Fluent:Button   Icon="Images\Settings_32x32.png" LargeIcon="Images\Settings_64x64.png"   
                                     Header="插件设置" 
                                     Command="Commands:iConverterCommands.SettingsCommand"  
                                     CommandParameter="{x:Static iConverter:OptionTabs.Plugins}"   />

                    <Fluent:InRibbonGallery x:Name="irgPlugins"       Selectable="False" ItemsSource="{Binding PluginProcessers}"  >
                        <Fluent:InRibbonGallery.ItemTemplate>
                            <DataTemplate>
                                <Fluent:Button Header="{Binding Name}" 
                                               Icon="{Binding SmallIcon}" 
                                               LargeIcon="{Binding Icon}" 
                                               Command="Commands:iConverterCommands.ProcessCommand"  
                                               CommandParameter="{Binding}" 
                                                />
                            </DataTemplate>
                        </Fluent:InRibbonGallery.ItemTemplate>
                    </Fluent:InRibbonGallery>

                </Fluent:RibbonGroupBox>
            </Fluent:RibbonTabItem>



            <!--Contextual Tabs-->
            <Fluent:RibbonTabItem x:Name="rtiBatch" Header="批量处理" Group="{Binding ElementName=BatchTabGroup}">
                <Fluent:RibbonGroupBox       Header="批量转换">
                    <!--<Fluent:MenuItem  Header="批量转换设置"  />-->
                    <!--<Fluent:CheckBox  Header="跳过对源文件编码是UTF-8的文件" />-->

                    <Fluent:Button   Icon="Images\Convert_32x32.png"  LargeIcon="Images\Convert_64x64.png"   Header="全部转换"  Command="Commands:iConverterCommands.BatchConvertCommand" />


                    <Fluent:Button     Icon="Images\Settings_32x32.png" LargeIcon="Images\Settings_64x64.png"  Header="批量转换选项"   Command="Commands:iConverterCommands.SettingsCommand" CommandParameter="{x:Static iConverter:OptionTabs.Batch}"  />
                </Fluent:RibbonGroupBox>
            </Fluent:RibbonTabItem>


           
        </Fluent:Ribbon>

       
        <Grid Grid.Row="1" >


            <TabControl x:Name="tabControl" TabStripPlacement="Top" Style="{DynamicResource DocumentTabControlStyle}"
                        ItemsSource="{Binding DocumentCollection}" SelectedIndex="{Binding Path=SelectDocumentIndex,Mode=TwoWay}"
                          >




            </TabControl>
        </Grid>

        
    </Grid>
</Fluent:RibbonWindow>
